package com.application.chiettinhdienluc.data;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import android.os.Environment;

import com.application.chiettinhdienluc.control.HinhAnhInfoListControl;
import com.application.chiettinhdienluc.control.NhanCongInfoListControl;
import com.application.chiettinhdienluc.control.VattuInfoListControl;
import com.application.chiettinhdienluc.model.ChietTinhModel;
import com.application.chiettinhdienluc.model.VatTuChiTietModel;

public class GlobalData {
	protected static boolean bActiveEvent = true;
	protected static int iTimeDisplaySplash = 3000;
	public static boolean isDone = false;
	public static boolean isDoneNhanCong = false;
	public final static String APP_NAME = "chiettinhdienluc";

	public final static String sdcardPath = Environment.getExternalStorageDirectory().getPath();
	public static String dataPath = "";
	public static String DB_PATH = "";
	public static VattuInfoListControl SelectedVatTuList = new VattuInfoListControl();
	public static NhanCongInfoListControl SelectedNhanCongList = new NhanCongInfoListControl();
	
	public static HinhAnhInfoListControl HinhAnhList = new HinhAnhInfoListControl();
	
	public static List<String> vattuInfoListInDB = new ArrayList<String>();
	public static List<String> nhancongInfoListInDB = new ArrayList<String>();
	
	public static double ChiPhiVatTu;
	public static double ChiPhiNhanCong;

	// Content provider
	/**
	 * Authority for regular database of the application.
	 */
	public static final String AUTHORITY = "com.application.chiettinhdienluc.db";

	/**
	 * Base content type for csipsimple objects.
	 */
	public static final String BASE_DIR_TYPE = "vnd.android.cursor.dir/vnd.chiettinhdienluc";
	/**
	 * Base item content type for csipsimple objects.
	 */
	public static final String BASE_ITEM_TYPE = "vnd.android.cursor.item/vnd.chiettinhdienluc";

	public static void initDataPath(String path) {
		// init value for data app path
		dataPath = path;
		DB_PATH =  path + "/databases/";
	}

	public static int widthDevice;
	public static int heightDevice;

	public static ChietTinhModel globalChietTinh = new ChietTinhModel();
	
	
	public static String getExternalStorageDirectory()
	{
		String chietTinhFolder = "/ChietTinh/";
		String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
		
		try {
			File myNewFolder = new File(extStorageDirectory + chietTinhFolder);
			myNewFolder.mkdir();
			createNoMediaFile(extStorageDirectory + chietTinhFolder);
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		return extStorageDirectory + chietTinhFolder;
	}
	
	public static void createNoMediaFile(String path)
	{
		try {
			String strFile = path + ".nomedia";		
			File file = new File(strFile);		
			if(!file.exists())
				file.createNewFile();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}